package org.yx.service.sres.view_maintain_items;

import org.dbist.dml.Page;
import org.dbist.dml.Query;
import org.yx.models.SresMtnDef;
import org.yx.utils.BaseService;

import com.xiaoleilu.hutool.util.StrUtil;

/**
 * 查看保养项目
 * 
 * @author zxw
 * @since 2019/08/31
 **/
public class SresViewMaintainItemsService extends BaseService {
	public SresViewMaintainItemsOut viewMaintainItems(SresViewMaintainItemsIn in) throws Exception {
		Query query = new Query(in.getPageIndex(), in.getPageSize());
		query.addFilter("orgCode", in.getUserOrgCode());
		query.addFilter("status", "<>", 'D');
		if (StrUtil.isNotBlank(in.getItemCode())) {
			query.addFilter("itemCode", "like", in.getItemCode() + "%");
		}
		query.addOrder("itemCode", false);

		Page<SresMtnDef> mtnItemPage = selectPage(SresMtnDef.class, query);

		SresViewMaintainItemsOut out = new SresViewMaintainItemsOut();
		out.setItemList(mtnItemPage.getList());
		out.setTotal(mtnItemPage.getTotalSize());

		return out;
	}
}